#include<stdio.h>
#include<math.h>

void Judge(char choice[30], int cons, int times);

int main()
{
    int n, pers, i, j;
    char choice[30];
    scanf("%d %d", &n, &pers);

    for(j = 0; j < pers; j++)
    {
        //input
        for(i = 0; i < n; i ++)
        {
            scanf(" %c", &choice[i]);
        }
		getchar();
		
        //judge and print
        Judge(choice, pow(2, n), n);
    }

    return 0;
}

void Judge(char choice[30], int cons, int times)
{
    int left = 0, right = cons, i = 0;
	
    while(times)
    {
        if(choice[i] == 'y') 
        {
            cons /= 2;
            right -= cons;
        }
        else if(choice[i] == 'n')
        {
            cons /= 2;
            left += cons;
        }
        i++;
        times--;
    }

	printf("%d\n", right);
}
